package com.hydl.power.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.hydl.power.pojo.ProtectDevice;
import com.hydl.power.service.ProtectDeviceService;
import com.hydl.power.utils.Resp;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @author Miss
 * @description 综保设备
 * @date 2023-01-07
 */
@RestController
@RequestMapping(value = "/protectDevice")
@Api(value = "ProtectDeviceController", tags = "综保设备管理")
@CrossOrigin
public class ProtectDeviceController {

    @Autowired
    private ProtectDeviceService protectDeviceService;

    /**
     * 新增
     *
     * @author Miss
     * @date 2023/01/07
     **/
    @PostMapping("/add")
    @ApiOperation(value = "新增")
    public Resp insert(ProtectDevice protectDevice) {
        protectDeviceService.insert(protectDevice);
        return Resp.success();

    }

    /**
     * 刪除
     *
     * @author Miss
     * @date 2023/01/07
     **/
    @PostMapping("/delete")
    @ApiOperation(value = "刪除")
    public Resp delete(@RequestParam int id) {
        protectDeviceService.delete(id);
        return Resp.success();
    }

    /**
     * 更新
     *
     * @author Miss
     * @date 2023/01/07
     **/
    @PostMapping("/update")
    @ApiOperation(value = "更新")
    public Resp update(ProtectDevice protectDevice) {
        protectDeviceService.update(protectDevice);
        return Resp.success();
    }

    /**
     * 查询 根据主键 id 查询
     *
     * @author Miss
     * @date 2023/01/07
     **/
    @PostMapping("/load")
    @ApiOperation(value = "查询-根据主键id查询")
    public Resp load(@RequestParam int id) {
        return Resp.success(protectDeviceService.load(id));
    }

    /**
     * 查询 分页查询
     *
     * @author Miss
     * @date 2023/01/07
     **/
    @PostMapping("/selectPage")
    @ApiOperation(value = "查询-分页查询")
    public Resp pageList(@RequestParam Integer pageNum, @RequestParam Integer pageSize, ProtectDevice protectDevice) {
        PageInfo<ProtectDevice> list = protectDeviceService.pageList(pageNum, pageSize, protectDevice);
        return Resp.success(list);
    }

    @PostMapping("/query")
    @ApiOperation(value = "查询")
    public Resp query(ProtectDevice protectDevice) {
        List list = protectDeviceService.query(protectDevice);
        return Resp.success(list);
    }
}